package webServer

import (
	"fmt"

	"gitee.com/JackieCode/fabric-go-api/webServer/controller"

	"github.com/gin-gonic/gin"
	"github.com/spf13/viper"
)

var Version = "UNKNOW VERSION"

func New() {
	router := gin.Default()
	router.GET("/version", func(c *gin.Context) {
		c.String(200, Version)
	})
	controller.ConfigUserRouter(router.Group("/user"))
	controller.ConfigBlockRouter(router.Group("/block"))
	controller.ConfigChaincodeRouter(router.Group("/chaincode"))
	fmt.Println("Version:", Version)
	router.Run(fmt.Sprintf(":%d", viper.GetInt("port")))
}
